<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>My JSP 'useraddfile.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/css/layui.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui.js"></script>
</head>

<body>
	<div class="layui-upload" style="position: relative;top:40px;left:15px">
		<button type="button" class="layui-btn layui-btn-normal"
			id="addfile">选择文件</button>
		<button type="button" class="layui-btn" id="test9">
			<i class="am-icon-upload"></i>开始上传
		</button>
	</div>
	<div style="position: relative;top:80px;left:15px">
		<form action="mobandown">
			<button type="submit" class="layui-btn" id="userfile">
				<i class="am-icon-download"></i>模板下载
			</button>
		</form>
	</div>
</body>
<script type="text/javascript">
	layui.use([ 'layer', 'table', 'laypage', 'upload' ], function() {
		var layer = layui.layer //获得layer模块
		, table = layui.table, page = layui.laypage;
		var upload = layui.upload;
		upload.render({
			elem : '#addfile',
			url : '${pageContext.request.contextPath}/tree/upload',
			accept : 'file',
			auto : false,
			bindAction : '#test9',
			done : function(res) {
				
				console.log(res);
				
				 var res1=JSON.stringify(res);
 
				 var jsObject = JSON.parse(res1);
			 
				 var resul="";
				 for(var i=0;i<jsObject.length;i++){
					 resul=jsObject[i].result;  //取json中的值
				}
				layer.alert(resul, {
					skin : 'layui-layer-molv' //样式类名
					,
					closeBtn : 0,
					end : function() {
						location.reload();
					}
				}, function() {
					layer.closeAll();
				}); 
			}
		});

	});
</script>

</html>
